<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="./js/jquery-3.4.1.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
</head>
<body>
<form action="login" onsubmit="return false">
	<input name="uname" />
	<button class="btn">登录</button>
</form>
<script>

	$.ajaxSetup({
		xhrFields: {
			withCredentials: true //允许跨域带Cookie
		}
	})
	$(".btn").on("click", () => {

		$.post("login2", $("form:eq(0)").serialize(), (data)=>{
			if (data == "success") {
				// JWT----
				$.cookie('uname', $("[name='uname']").val() , { expires: 7 });
				location.href="welcome.html"
			}
		}, "text")


	})


</script>
</body>
</html>